/**************************************************************************
* This file is part of Hawkengine.
**
* Hawkengine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
**
* Hawkengine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
**
* You should have received a copy of the GNU Lesser General Public License
* along with Hawkengine.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#ifndef _JAVA_ENGINE_H_
#define _JAVA_ENGINE_H

/**************************************************************************
* Dependencies
**************************************************************************/
#include "engine/engine.h"
#include <jni.h>

/**************************************************************************
* Preprocessing
**************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

#if !defined(JAVA_PACKAGE)
#  if defined(HAWKENGINE_APP)
#    define JAVA_PACKAGE _CONCAT(HAWKENGINE_PACKAGE,HAWKENGINE_APP)
#  else
#    define JAVA_PACKAGE
#  endif
#endif
#define JAVA_CLASS _CONCAT(Java_,_CONCAT(JAVA_PACKAGE,_Engine_))
#define JAVA_METHOD(method) _CONCAT(JAVA_CLASS,method)
#define JAVA_SIGNATURE(ret,method) ret JAVA_METHOD(method)

#if defined(JAVA_STATIC_METHODS)
#  define JAVA_OBJECT_TYPE jclass
#  define GET_METHOD_FUNC GetStaticMethodID
#  define CALL_BOOLEAN_FUNC CallStaticBooleanMethod
#  define CALL_INT_FUNC CallStaticIntMethod
#  define GET_OBJECT_CLASS(jobj) jobj
#else
#  define JAVA_OBJECT_TYPE jobject
#  define GET_METHOD_FUNC GetMethodID
#  define CALL_BOOLEAN_FUNC CallBooleanMethod
#  define CALL_INT_FUNC CallIntMethod
#  define GET_OBJECT_CLASS(jobj) (*engine_jenv)->GetObjectClass(engine_jenv, jobj)
#endif
#define JAVA_PARAMS JNIEnv* jenv, JAVA_OBJECT_TYPE jobj

/**************************************************************************
* Types
**************************************************************************/

/**************************************************************************
* Variables
**************************************************************************/
extern JNIEnv* engine_jenv;
extern JAVA_OBJECT_TYPE engine_jobj;

/**************************************************************************
* Static Variables
**************************************************************************/

/**************************************************************************
* Function Prototypes
**************************************************************************/

/**************************************************************************
* Function Implementations
**************************************************************************/


#ifdef __cplusplus
}
#endif

#endif
